#include <iostream>
#include <cstdio>
using namespace std;
template <typename T>
struct Queue{
int tail=0, head=0, size, occ=0;
T* data;
Queue(int _size): size(_size) {
data=new T[size];
}
~Queue(){
delete[] data;
}
bool empty(void){
if(this->head==this->tail) return true;
else return false;
}
void enqueue(T x){
if(this->occ==this->size){
perror("Queue Overflow");
exit(1);
} else {
this->data[this->tail]=x;
if(this->tail==this->size-1) this->tail=0;
else this->tail++;
occ++;
}
}
T dequeue(void){
if(this->occ==0){
perror("Queue Underflow");
exit(1);
} else {
int x=this->data[this->head];
if(this->head==this->size-1){
this->head=0;
} else {
this->head++;
}
occ--;
return x;
}
}
};
int main(void){
Queue<int> queue(5);
queue.enqueue(10);
queue.enqueue(5);
queue.enqueue(1);
queue.enqueue(3);
queue.enqueue(6);
cout<<queue.dequeue()<<'\n';
cout<<queue.dequeue()<<'\n';
cout<<queue.dequeue()<<'\n';
cout<<queue.dequeue()<<'\n';
cout<<queue.dequeue()<<endl;
return 0;
}